﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChuyenNhanSuKienWinDows
{
    public partial class Form1 : Form
    {
        HookManager _hookManager;

        public Form1()
        {
            InitializeComponent();

            _hookManager = new HookManager();
            _hookManager.Install();

            _hookManager.KeyDown += (sender, e) =>
                {
                    txtNhanPhim.AppendText(e.KeyCode + " ");
                    txtNhanPhim.SelectionStart = txtNhanPhim.Text.Length;
                };
            _hookManager.MouseClick += (sender, e) =>
            {
                lbToaDoChuot.Text = String.Format("x={0}  y={1} ", e.X, e.Y);
                if (e.Clicks > 0)
                {
                    txtNhanPhim.AppendText("Nhấn Chuột: " + e.Button + "     x=" + e.X + " y=" + e.Y + Environment.NewLine);
                    txtNhanPhim.SelectionStart = txtNhanPhim.Text.Length;
                }
            }; 
        }
    }
}
